<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <script src="../lib/vue2.js"></script>
  </head>
  <body>
    <div id="box">
      <div v-on:click="print">click</div>
      <!-- 可以简写为@符号 -->
      <div @click="shift">{{flag}}</div>
    </div>

    <script>
      let item = new Vue({
        el: "#box",
        data: {
          flag: true,
        },
        // methonds中写方法
        methods: {
          print() {
            console.log("1");
          },
          shift() {
            this.flag = !this.flag;
          },
        },
      });
    </script>
  </body>
</html>
